package com.app.view.component.dialogs 
{
	import flash.display.SimpleButton;
	import flash.text.TextField;
	import flash.events.MouseEvent;
	
	import org.component.Button;
	
	import com.peachcastle.core.Dialog;
	import com.app.view.manager.DialogManagerMediator;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class SystemTipView extends Dialog
	{
		private var _dialogManagerMediator:DialogManagerMediator = null;
		
		private var _btn_close:SimpleButton = null;
		private var _txt_content:TextField = null;
		private var _btn_confirm:Button = null;
		
		public function SystemTipView(dialogUrlFunc:Function, dialogManagerMediator:DialogManagerMediator) 
		{
			_dialogManagerMediator = dialogManagerMediator;
			super("SystemTipView", true, dialogUrlFunc,
					_dialogManagerMediator.stageSize["width"], _dialogManagerMediator.stageSize["height"]);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			super.setCenter();
			
			_btn_close = assest["btn_close"];
			_btn_confirm = new Button(assest["btn_confirm"]);
			_txt_content = assest["txt_content"];
		}
		
		override protected function configureEventListeners():void 
		{
			super.configureEventListeners();
			_btn_close.addEventListener(MouseEvent.CLICK, onClose);
			_btn_confirm.addEventListener(MouseEvent.CLICK, onClose);
		}
		
		override protected function showAction():void 
		{
			super.showAction();
			
			_txt_content.text = String(data["msg"]);
		}
		
		private function onClose(event:MouseEvent):void
		{
			super.hide();
			
			if (data.hasOwnProperty('callback') && data['callback'] != null)
			{
				var func:Function = data['callback'];
				func();
			}
		}
	}

}